//
//  NSRectFunctions.h
//  ubixar-utils
//
//  Created by Demis Bellot on 17/04/2009.
//  Copyright 2009 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import <Foundation/Foundation.h>

NSPoint UKCenterOfRect( NSRect rect )
{
	return NSMakePoint( NSMidX(rect), NSMidY(rect) );
}

inline NSPoint  UKTopCenterOfRect( NSRect rect )
{
	return NSMakePoint( NSMidX(rect), NSMaxY(rect) );
}

inline NSPoint  UKTopLeftOfRect( NSRect rect )
{
	return NSMakePoint( NSMinX(rect),NSMaxY(rect) );
}

inline NSPoint  UKTopRightOfRect( NSRect rect )
{
	return NSMakePoint( NSMaxX(rect), NSMaxY(rect) );
}

inline NSPoint  UKLeftCenterOfRect( NSRect rect )
{
	return NSMakePoint( NSMinX(rect), NSMidY(rect) );
}

inline NSPoint  UKBottomCenterOfRect( NSRect rect )
{
	return NSMakePoint( NSMidX(rect), NSMinY(rect) );
}

inline NSPoint  UKBottomLeftOfRect( NSRect rect )
{
	return rect.origin;
}

inline NSPoint  UKBottomRightOfRect( NSRect rect )
{
	return NSMakePoint( NSMaxX(rect), NSMinY(rect) );
}

inline NSPoint  UKRightCenterOfRect( NSRect rect )
{
	return NSMakePoint( NSMaxX(rect), NSMidY(rect) );
}

inline NSRect NKScaleRect(NSRect inRect, float scaleX, float scaleY)
{	
	NSRect outRect = inRect;
	outRect.size.width  += scaleX * inRect.size.width;
	outRect.size.height += scaleY * inRect.size.height;
	
	outRect.origin.x -= (outRect.size.width - inRect.size.width) / 2.0;
	outRect.origin.y -= (outRect.size.height - inRect.size.height) / 2.0;
	
	return outRect;
}